use sea_orm::Set;
use crate::api::account_info_request::AccountInfoListResp;
use crate::entity::account_info;
use crate::map_fields;
use crate::utils::app::to_json_string;
use crate::entity::account_info::ActiveModel;

pub fn convert_account_active_model(resp: &AccountInfoListResp) -> ActiveModel {
    // let mut model = ActiveModel{
    //  ..Model::default().into()
    // };
    let mut model = account_info::ActiveModel {
        ..Default::default()
    };

    // 使用宏映射所有可选字段
    map_fields!(
        active model,
        resp,
        zh, zh_type, serid,
        zhw_hid, zhw_zt, zhw_money,
        uhz_hid, uhz_zt, uhz_money,
        zz_hid, zz_zt, zz_money
    );

    // 处理特殊字段
    model.zh_cfg = Set(to_json_string(resp.zh_cfg.clone()));

    model
}